package com.ai.mall.controller.admin;

import com.ai.mall.entity.ProductRecommendationsEntity;
import com.ai.mall.service.ProductRecommendationsService;
import com.ai.mall.utils.PageUtils;
import com.ai.mall.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 商品推荐表
 *
 * @author easue
 * @email sunlightcs@gmail.com
 * @date 2025-01-21 14:40:34
 */
@RestController
@RequestMapping("mall/productrecommendations")
public class ProductRecommendationsController {
    @Autowired
    private ProductRecommendationsService productRecommendationsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("mall:productrecommendations:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = productRecommendationsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{recommendationId}")
    //@RequiresPermissions("mall:productrecommendations:info")
    public R info(@PathVariable("recommendationId") Integer recommendationId){
		ProductRecommendationsEntity productRecommendations = productRecommendationsService.getById(recommendationId);

        return R.ok().put("productRecommendations", productRecommendations);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mall:productrecommendations:save")
    public R save(@RequestBody ProductRecommendationsEntity productRecommendations){
		productRecommendationsService.save(productRecommendations);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mall:productrecommendations:update")
    public R update(@RequestBody ProductRecommendationsEntity productRecommendations){
		productRecommendationsService.updateById(productRecommendations);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mall:productrecommendations:delete")
    public R delete(@RequestBody Integer[] recommendationIds){
		productRecommendationsService.removeByIds(Arrays.asList(recommendationIds));

        return R.ok();
    }

}
